package cn.xiao;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;

public class Demo {


    public static void main(String[] agrs) throws URISyntaxException, IOException {

        FileSystem fs = FileSystem.get(new URI("hdfs://127.0.0.1:9000"), new Configuration());


        InputStream in = fs.open(new Path("/in.log"));

        OutputStream out = new FileOutputStream("/root/in.log");

        // 为什么给4096， 默认4096，   true 关闭流
        IOUtils.copyBytes(in, out, 4096, true);


    }
}
